//1.引入express框架模块
var express = require('express');
//2.创建框架核心app对象
var app = express();
//3.路由


/*3.1   get和post*/
/*app.get('/',  function(req, res) {
    //注：修改method=get 或者 method=post查看结果
    var formHtml = `
		<form action="/test" method="post">
			<input type="text" name="uname" />
			<input type="text" name="age" />
			<input type="submit"  />
		</form>
	`;
    res.send(formHtml);
});
app.get('/test', function(req, res){
    res.send('this is get submit');
});

app.post('/test', function(req, res){
    res.send('this is post submit');
});*/


/*3.2   use的不完全匹配*/
/*app.get('/', function (req, res) {
    let html = `
        <form action="/test/a" method="post">
        <input type="text" name="uname" />
			<input type="text" name="age" />
			<input type="submit"  />
</form>
    `;
    res.send(html);
});
app.use('/test', function (req, res) {
    res.send('this is test....');
});*/

/*3.3 路由传参*/
app.get('/stu/:name/:age', function(req, res){
    console.log(req.params);
    res.send('匹配成功，快去看控制台有没有获取数据..')
});

//4.启动服务
app.listen(8080, function(){
    console.log('Running...');
});